<?php

/**
 * TurmasTextos
 *  
 * @author Milton Jr.
 * @version 1.0
 */

require_once 'Zend/Db/Table/Abstract.php';

class TurmasTextos extends Zend_Db_Table_Abstract {

	protected $_name = 'publicacoes';
	
    protected $_referenceMap    = array(
        'Texto' => array(
            'columns'           => 'id_texto',
            'refTableClass'     => 'Textos',
            'refColumns'        => 'id',
            
        ), 
        'Turmas' => array(
            'columns'           => 'id_turma',
            'refTableClass'     => 'Turmas',
            'refColumns'        => 'id',
        )
        
	);
	
	
	public function insert(array $dados) {
		
		parent::insert ( $dados );
	}
	
    /**
     * 
     * @param int turma, int texto
     * @return bool
     */
	public function findbyTextoPublicado($turma, $texto) {
		
		return($this->fetchAll ( $this->getAdapter ()->quoteInto ( 'id_turma = ?', $turma ). " AND ".
		$this->getAdapter ()->quoteInto ( 'id_texto = ?', $texto ) ));
			
		
	}
	
	/**
	 * Retirar publica��o do banco
	 * 
	 * @param int id_turma, int id_texto
	 */
	public function deleteTurma($id_turma, $id_texto) {
		$where  = $this->getAdapter ()->quoteInto ( 'id_turma = ?', $id_turma) . " AND " . $this->getAdapter ()->quoteInto ('id_texto = ?', $id_texto );
		
		parent::delete($where);
	}
	

}
